package com.group.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.group.pojo.TbBill;
import com.group.pojo.TbContract;
import com.group.pojo.TbCustomer;
import com.group.service.BillService;

/**
 * 我要报修控制器
 * @author caoyanan
 * @time 2017年12月27日下午11:26:12
 */
@Controller
@RequestMapping("/bill")
public class BillController {
     @Autowired
     private BillService billService;
     
     
     //查询客户信息
     @RequestMapping("/page.action")
     public String page(){
    	 return "bill";
     }
     //查询设备详情页面
     @RequestMapping("/deviceDetail.action")
     public String deviceDetail(String deviceId, String contractId,Model m){
    	 m.addAttribute("deviceId", deviceId);
    	 m.addAttribute("contractId", contractId);
    	 return "device-detail";
     }
     //报修提交
     @RequestMapping("/form.action")
	 public String form(String contractId,Model m){
    	 m.addAttribute("contractId", contractId);
    	 return "bill-form";
     }
     //进度查看
     @RequestMapping("/process.action")
     public String process(){
    	 return "process";
     }
     //进度查看
     @RequestMapping("/queryProcess.action")
     @ResponseBody
     public List<TbBill> queryProcess(HttpServletRequest request){
    	 TbBill bill = new TbBill();
    	 TbCustomer cus = (TbCustomer) request.getSession().getAttribute("CUSTOMER_SESSION");
 		 bill.setCustomerId(cus.getId());
    	 List<TbBill> list = billService.query(bill);
    	 return list;
     }
     
     
	//保存
	@RequestMapping("/save.action")
	@ResponseBody
	public Map<String, String> save(HttpServletRequest request, TbBill bill, MultipartFile billImg) {
		Map<String, String> map = billService.save(request, bill, billImg);
		return map;
	}
	
	//保存
	@RequestMapping("/update.action")
	@ResponseBody
	public Map<String, String> update(TbBill bill, HttpServletRequest request) {
		Map<String, String> map = billService.update(bill, request);
		return map;
	}
	
	//保存
	@RequestMapping("/submitAddress.action")
	@ResponseBody
	public Map<String, String> update(HttpServletRequest request, TbBill bill) {
		Map<String, String> map = billService.submitAddress(request, bill);
		return map;
	}
     
}























